package main

import (
	"flag"
	"fmt"
	"iot-base/common/config"
	"iot-base/common/tunnel/edge"
)

/*
42.192.199.243
unbutun
!9kuHV7$6v/n
edge.exe -ip 42.192.199.243 -port 39999 -id chen.a.b
*/
var ip = flag.String("ip", "42.192.199.243", "云端服务器ip地址")
var port = flag.Int("port", 39999, "云端服务器端口")
var id = flag.String("id", config.SelfOption.ID, "边缘id")

func main() {
	flag.Parse()
	var name string = "@edge"
	if id != nil && *id == "self" {

		id = &config.SelfOption.ID
		name = config.SelfOption.Name
	}
	if ip == nil || *ip == "" {
		sip := "42.192.199.243"
		ip = &sip
	}
	if port == nil || *port == 0 {
		nport := 39999
		port = &nport
	}
	fmt.Println("------------", *ip, *port, *id, name)
	edge.BeginTunnel(*ip, *port, *id, name)
}
